package com.qili.controller;

import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.inject.internal.util.$AsynchronousComputationException;
import com.qili.annotation.Mean;
import com.qili.base.entity.CurrentUser;
import com.qili.core.utils.DictTypes;
import com.qili.core.utils.DictUtil;
import com.qili.entity.affaircase.AffairCase;
import com.qili.entity.affaircase.AffairRecord;
import com.qili.entity.affaircase.dto.AffairCaseDTO;
import com.qili.entity.affaircase.dto.AffairRecordDTO;
import com.qili.entity.base.BaseCompany;
import com.qili.entity.base.BaseCompanyOwner;
import com.qili.entity.base.BaseDict;
import com.qili.entity.jc.JcProject;
import com.qili.entity.supervisor.*;
import com.qili.entity.supervisor.dto.ProjectLeaderDTO;
import com.qili.entity.supervisor.dto.ProjectUnitConstructionDTO;
import com.qili.entity.supervisor.dto.SupervisorProjectDTO;
import com.qili.entity.supplier.*;
import com.qili.entity.supplier.dto.ProjectPlaceChangeDTO;
import com.qili.entity.supplier.dto.ProjectPlaceDTO;
import com.qili.entity.supplier.dto.SupplierProjectChangeDTO;
import com.qili.entity.supplier.dto.SupplierProjectDTO;
import com.qili.entity.sys.SysRegion;
import com.qili.entity.sys.SysUser;
import com.qili.entity.sys.dto.SysUserDTO;
import com.qili.entity.zx.ZxProject;
import com.qili.entity.zx.dto.ZxProjectDTO;
import com.qili.service.AffairService;
import com.qili.service.SysUserService;
import com.qili.service.WorkflowService;
import com.qili.service.affairCase.AffairCaseService;
import com.qili.service.affairCase.AffairRecordService;
import com.qili.service.base.BaseCompanyOwnerService;
import com.qili.service.base.BaseCompanyService;
import com.qili.service.base.BaseDictService;
import com.qili.service.jc.JcProjectService;
import com.qili.service.supervisor.*;
import com.qili.service.supplier.*;
import com.qili.service.supplier.ProjectPlaceService;
import com.qili.service.sys.SysRegionService;
import com.qili.service.zx.ZxProjectService;
import com.qili.util.*;
import lombok.extern.java.Log;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;

/**
 * @author zhaoyongke
 * @date 2020/12/7
 * @description 监理流程管理
 */
@Log
@Controller
@RequestMapping("/supervisor/lcManager")
public class SupervisorLcController {
    @Autowired
    SupervisorProjectService supervisorProjectService;
    @Autowired
    SupervisorFileService supervisorFileService;
    @Autowired
    AffairCaseService affairCaseService;
    @Autowired
    AffairRecordService affairRecordService;
    @Autowired
    SysUserService sysUserService;
    @Autowired
    ProjectLeaderService projectLeaderService;
    @Autowired
    ProjectContractService projectContractService;
    @Autowired
    ProjectAdminService projectAdminService;
    @Autowired
    WorkflowService workflowService;
    @Autowired
    ProjectUnitConstructionService projectUnitConstructionService;
    @Autowired
    ProjectSealRecordService projectSealRecordService;
    @Autowired
    ProjectNoticeServie projectNoticeServie;
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private TaskService taskService;
    @Autowired
    SupplierProjectManagerService supplierProjectManagerService;
    @Autowired
    ProjectPlaceService projectPlaceService;
    @Autowired
    SysRegionService sysRegionService;
    @Autowired
    BaseDictService baseDictService;
    @Autowired
    SupplierProjectManagerChangeService supplierProjectManagerChangeService;
    @Autowired
    ProjectPlaceChangeService projectPlaceChangeService;
    @Autowired
    SupervisorFileTempService supervisorFileTempService;
    @Autowired
    SupervisorProjectModifiedRecordService supervisorProjectModifiedRecordService;
    @Autowired
    SupplierProjectAcceptService supplierProjectAcceptService;
    @Autowired
    BaseCompanyService baseCompanyService;
    @Autowired
    AffairService affairService;

    @Autowired
    ZxProjectService zxProjectService;

    @Autowired
    JcProjectService jcProjectService;

    @Autowired
    private BaseCompanyOwnerService baseCompanyOwnerService;

    @GetMapping("processCheckDetail")
    public String processCheckDetail(AffairCaseDTO dto, Model model, HttpServletRequest request) {
        String url = "";
        try {
            AffairCase affairCase = new AffairCase();
            affairCase.setCaseId(dto.getCaseId());
            affairCase = affairCaseService.selectByPrimaryKey(affairCase);
            String yqType = dto.getLcType();// 流程查看类型 1  代办 2 已办  3 已办结 4 我的请求 5 审批进程
            if ("000".equals(affairCase.getLcType())) {
                BeanUtil.copyNotNullBean(affairCase, dto);
                dto.setLcType(yqType);
                url = viewFxCheckDetail(dto, model);
                model.addAttribute("businessId", affairCase.getBusinessId());
            } else {
                dto.setApplicantType(affairCase.getApplicantType());
                url = viewLcDetail(dto, model);
                if (StringUtil.isNotBlank(url)) {
                    return url;
                } else {
                    url = "/act/supervisor/processCheckDetail";
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;

    }


    /**
     * @param dto
     * @param model
     * @param request
     * @Author:zhaoyongke
     * @Description: 审批意见
     * @Date:14:48 2021/1/30
     */
    @GetMapping("checkRemark")
    public String checkRemark(AffairCaseDTO dto, Model model, HttpServletRequest request) {
        String taskId = dto.getTaskId();
        String taskName = dto.getTaskName();
        String caseId = dto.getCaseId();
        String processInstanceId = dto.getProcessInstanceId();
        String businessId = dto.getBusinessId();
        /*是否需要签字*/
        String isqz = request.getParameter("isqz");
        /*审核意见加载*/
        List<BaseDict> remarklist = DictUtil.getDictByType(DictTypes.SHYJ);
        model.addAttribute("remarklist", remarklist);
        model.addAttribute("taskId", taskId);
        model.addAttribute("taskName", taskName);
        model.addAttribute("processInstanceId", processInstanceId);
        model.addAttribute("businessId", businessId);
        model.addAttribute("isqz", isqz);
        model.addAttribute("caseId", caseId);
        return "/act/supervisor/checkRemark";
    }

    /**
     * @param dto
     * @param model
     * @Author:zhaoyongke
     * @Description:
     * @Date:15:57 2021/3/27
     */
    public String viewFxCheckDetail(AffairCaseDTO dto, Model model) throws Exception {
        String projectId = dto.getBusinessId();
        String detailUrl = getProjectDetail(model, projectId);
        String caseId = dto.getCaseId();
        String taskId = dto.getTaskId();
        String yqType = dto.getLcType();// 流程查看类型 1  代办 2 已办  3 已办结 4 我的请求 5 审批进程
        String taskName = dto.getTaskName();
        model.addAttribute("caseId", caseId);
        model.addAttribute("taskId", taskId);
        model.addAttribute("taskName", taskName);
        // 2021 0906 修改 审核后刷新页面 防止出现 审核刷新后还显示 审核按钮 ，通过是否完成 事项表判断
        AffairCase affairCase = affairCaseService.selectByPrimaryKey(caseId);
        String endresult ="";
        if(affairCase!=null){
            endresult = affairCase.getEndresult();
        }
        // 查看有没有代办
        if ("1".equals(yqType)  && !"1".equals(endresult)) {
            model.addAttribute("check", "1");
        }
        model.addAttribute("checkedit", "1");
        return detailUrl;
    }

    /**
     * @param model
     * @param projectId
     * @Author:zhaoyongke
     * @Description:
     * @Date:15:41 2021/3/27
     */
    public String getProjectDetail(Model model, String projectId) {

        SupplierProjectDTO supplierProjectDTO1 = new SupplierProjectDTO();
        supplierProjectDTO1.setSupProjectId(projectId);
        List<SupplierProjectDTO> supplierProjectDTOS = supplierProjectManagerService.selectProject(supplierProjectDTO1);
        String publishType = "";
        if (supplierProjectDTOS.size() > 0) {
            SupplierProjectDTO projectDTO = supplierProjectDTOS.get(0);
            String pubComType = projectDTO.getPubComType();
            if ("001".equals(pubComType)) {
                BaseCompany baseCompany = baseCompanyService.selectByPrimaryKey(projectDTO.getPublishCompany());
                model.addAttribute("comName", baseCompany.getBcName());
            } else {
                SysUser sysUser = sysUserService.selectByPrimaryKey(projectDTO.getPublishCompany());
                model.addAttribute("comName", sysUser.getCompanyName());
            }
            publishType = projectDTO.getPublishType();
            String status = projectDTO.getStatus();
            String checkStatus = projectDTO.getCheckStatus();
            if ("006".equals(status) && "1".equals(checkStatus)) {
                SupplierProjectChangeDTO changeDTO = supplierProjectManagerChangeService.getChangeProject(projectDTO);
                model.addAttribute("project", changeDTO);
                //处理实施地点和人员地点要求
                getProjectPlaceChange(model, projectDTO.getSupProjectId(), changeDTO.getSupProjectChangeId());
                SupplierProjectDTO dicprodto = new SupplierProjectDTO();
                BeanUtil.copyNotNullBean(changeDTO, dicprodto);
                //处理字典
                getProjectDic(model, dicprodto);
                // 查询文件
                // 获取文件
                SupervisorFileTemp tempfile = new SupervisorFileTemp();
                tempfile.setLinkId(changeDTO.getSupProjectChangeId());
                List<SupervisorFileTemp> selectfile = supervisorFileTempService.select(tempfile);
                model.addAttribute("filelist", selectfile);
                //是否显示变更列表（审核页面）
                model.addAttribute("bgcheck", "1");



            } else {
                model.addAttribute("project", projectDTO);
                //处理实施地点和人员地点要求
                getProjectPlace(model, projectDTO.getSupProjectId());
                //处理字典
                getProjectDic(model, projectDTO);
                // 获取文件
                SupervisorFileTemp tempfile = new SupervisorFileTemp();
                tempfile.setLinkId(projectId);
                List<SupervisorFileTemp> selectfile = supervisorFileTempService.select(tempfile);
                model.addAttribute("filelist", selectfile);

            }

        }
        // 项目归属
        List<BaseCompanyOwner> alstCompanyGs = baseCompanyOwnerService.selectAll();
        model.addAttribute("comlistOwner", alstCompanyGs);
        String url = "";
        if ("001".equals(publishType)) {
            //正中内部发布
            url = "projectManager/projectDetailXfNb";
        } else {
            url = "projectManager/projectDetailXfWb";

        }

        return url;
    }


    /**
     * @param model
     * @param projectId
     * @param proChangeId
     * @Author:zhaoyongke
     * @Description: 获取变更后的地点
     * @Date:15:43 2021/3/29
     */
    public void getProjectPlaceChange(Model model, String projectId, String proChangeId) {
        // 实施地点
        ProjectPlaceChangeDTO dto = new ProjectPlaceChangeDTO();
        dto.setSupProjectId(projectId);
        dto.setSupProjectChangeId(proChangeId);
        dto.setType("001");
        List<ProjectPlaceChangeDTO> listpalce = projectPlaceChangeService.selectPlace(dto);
        for (int i = 0; i < listpalce.size(); i++) {
            String province = listpalce.get(i).getProvince();
            List<SysRegion> citylist = sysRegionService.selectSysRegionByParentCode(province);
            listpalce.get(i).setCitys(citylist);
            String city = listpalce.get(i).getCity();
            List<SysRegion> countylist = sysRegionService.selectSysRegionByParentCode(city);
            listpalce.get(i).setCountys(countylist);
        }
        model.addAttribute("listpalce", listpalce);
        // 人员地点
        ProjectPlaceChangeDTO dtopersonplace = new ProjectPlaceChangeDTO();
        dtopersonplace.setSupProjectId(projectId);
        dtopersonplace.setSupProjectChangeId(proChangeId);
        dtopersonplace.setType("002");
        List<ProjectPlaceChangeDTO> listPersonPalce = projectPlaceChangeService.selectPlace(dtopersonplace);
        for (int i = 0; i < listPersonPalce.size(); i++) {
            String province = listPersonPalce.get(i).getProvince();
            List<SysRegion> citylist = sysRegionService.selectSysRegionByParentCode(province);
            listPersonPalce.get(i).setCitys(citylist);
            String city = listPersonPalce.get(i).getCity();
            List<SysRegion> countylist = sysRegionService.selectSysRegionByParentCode(city);
            listPersonPalce.get(i).setCountys(countylist);
        }
        model.addAttribute("listperpalce", listPersonPalce);
    }


    /**
     * @param model
     * @Author:zhaoyongke
     * @Description:
     * @Date:14:25 2021/3/24
     */
    public void getProjectDic(Model model, SupplierProjectDTO dto) {
        // 学历类型
        List<BaseDict> edulist = baseDictService.selectByTypeCode("XL001");
        /*项目类型*/
        List<BaseDict> projectTypeList = DictUtil.getDictByType(DictTypes.YW_TYPE);
        /*行业类型*/
        List<BaseDict> hyTypeList = DictUtil.getDictByType(DictTypes.INDUSTRY);
        //擅长领域
        List<BaseDict> doBestList = baseDictService.selectByTypeCode(DictTypes.DOBEST.getType());
        // 省
        List<SysRegion> provincelist = sysRegionService.selectListByLevelId("1");

        if (StringUtil.isNotBlank(dto.getMainFzField())) {
            String mainFzFieldstr = getLxText(dto.getMainFzField(), DictTypes.DOBEST.getType());
            model.addAttribute("strbest", mainFzFieldstr);
        }
        if (StringUtil.isNotBlank(dto.getProjectType())) {
            //項目類型
            String proTypestr = getLxText(dto.getProjectType(), DictTypes.YW_TYPE.getType());
            model.addAttribute("strprojecttype", proTypestr);
        }
        if (StringUtil.isNotBlank(dto.getHyType())) {
            //行业类型
            String hyTypestr = getLxText(dto.getHyType(), DictTypes.INDUSTRY.getType());
            model.addAttribute("hyTypestr", hyTypestr);
        }

        if (StringUtil.isNotBlank(dto.getSupervisorWay())) {
            // 监理形式
            String supervisorWay = getLxText(dto.getSupervisorWay(),DictTypes.CHECK_SHAPE.getType());
            model.addAttribute("supervisorWay", supervisorWay);
        }


        // 市
        List<SysRegion> citylist = sysRegionService.selectSysRegionByParentCode(dto.getHtSignProvince());
        // 县
        List<SysRegion> countylist = sysRegionService.selectSysRegionByParentCode(dto.getHtSignCity());


        model.addAttribute("citylist", citylist);
        model.addAttribute("countylist", countylist);
        model.addAttribute("projectTypeList", projectTypeList);
        model.addAttribute("hytypelist", hyTypeList);
        model.addAttribute("provincelist", provincelist);
        model.addAttribute("edulist", edulist);
        model.addAttribute("doBestList", doBestList);
    }

    public String getLxText(String field, String typecode) {
        List<BaseDict> codeList = baseDictService.selectByTypeCode(typecode);
        HashMap<String, String> mapbest = new HashMap();
        for (int i = 0; i < codeList.size(); i++) {
            mapbest.put(codeList.get(i).getBadtCode(), codeList.get(i).getBadtName());
        }
        //擅长领域
        List<String> dobest = StringUtil.split(field);
        List<String> best = new ArrayList<>();
        for (int i = 0; i < dobest.size(); i++) {
            String s = dobest.get(i);
            String scname = mapbest.get(s);
            best.add(scname);
        }
        String strbest = best.toString().replaceAll("\\[", "").replaceAll("\\]", "");
        return strbest;

    }

    /**
     * @param model
     * @param projectId
     * @Author:zhaoyongke
     * @Description:
     * @Date:14:29 2021/3/24
     */
    public void getProjectPlace(Model model, String projectId) {
        // 实施地点
        ProjectPlaceDTO dto = new ProjectPlaceDTO();
        dto.setSupProjectId(projectId);
        dto.setType("001");
        List<ProjectPlaceDTO> listpalce = projectPlaceService.selectPlace(dto);
        for (int i = 0; i < listpalce.size(); i++) {
            String province = listpalce.get(i).getProvince();
            List<SysRegion> citylist = sysRegionService.selectSysRegionByParentCode(province);
            listpalce.get(i).setCitys(citylist);
            String city = listpalce.get(i).getCity();
            List<SysRegion> countylist = sysRegionService.selectSysRegionByParentCode(city);
            listpalce.get(i).setCountys(countylist);
        }
        model.addAttribute("listpalce", listpalce);
        // 人员地点
        ProjectPlaceDTO dtopersonplace = new ProjectPlaceDTO();
        dtopersonplace.setSupProjectId(projectId);
        dtopersonplace.setType("002");
        List<ProjectPlaceDTO> listPersonPalce = projectPlaceService.selectPlace(dtopersonplace);
        for (int i = 0; i < listPersonPalce.size(); i++) {
            String province = listPersonPalce.get(i).getProvince();
            List<SysRegion> citylist = sysRegionService.selectSysRegionByParentCode(province);
            listPersonPalce.get(i).setCitys(citylist);
            String city = listPersonPalce.get(i).getCity();
            List<SysRegion> countylist = sysRegionService.selectSysRegionByParentCode(city);
            listPersonPalce.get(i).setCountys(countylist);
        }
        model.addAttribute("listperpalce", listPersonPalce);
    }


    /**
     * @param dto
     * @param model
     * @Author:zhaoyongke
     * @Description: 查看流程详情
     * @Date:14:05 2021/1/22
     */
    public String viewLcDetail(AffairCaseDTO dto, Model model) throws Exception {
        String url = "";
        String caseId = dto.getCaseId();
        String taskId = dto.getTaskId();
        String yqType = dto.getLcType();// 流程查看类型 1  代办 2 已办  3 已办结 4 我的请求 5 审批进程
        String taskName = dto.getTaskName();
        String applicantType = dto.getApplicantType();


        AffairCase affairCase = new AffairCase();
        affairCase.setCaseId(caseId);
        affairCase = affairCaseService.selectByPrimaryKey(affairCase);
        //查询发起人员信息 获取申报对象Id
        String userid = affairCase.getApplicantId();
        SysUser user = new SysUser();
        user.setId(userid);
        user = sysUserService.selectByPrimaryKey(user);
        //查询文件
        String businessId = affairCase.getBusinessId();
        SupervisorFile file = new SupervisorFile();
        file.setId(businessId);
        file = supervisorFileService.selectByPrimaryKey(file);
        if (file == null) {
            model.addAttribute("message", "您的文件不存在");
            url = "/error/lcerror";
            return url;
        }
        if("003".equals(applicantType)){
            //查询项目
             ZxProject project = new ZxProject();
            String projectId = file.getProjectId();
            project.setId(projectId);
            project = zxProjectService.selectByPrimaryKey(project);
            if (project == null) {
                model.addAttribute("message", "项目不存在");
                url = "/error/lcerror";
                return url;
            }
            model.addAttribute("project", project);

        }else if("004".equals(applicantType)){
            //查询项目
            JcProject project = new JcProject();
            String projectId = file.getProjectId();
            project.setId(projectId);
            project = jcProjectService.selectByPrimaryKey(project);
            if (project == null) {
                model.addAttribute("message", "项目不存在");
                url = "/error/lcerror";
                return url;
            }
            model.addAttribute("project", project);

        }else{
            //查询项目
            SupervisorProject project = new SupervisorProject();
            String projectId = file.getProjectId();
            project.setId(projectId);
            project = supervisorProjectService.selectByPrimaryKey(project);
            if (project == null) {
                model.addAttribute("message", "项目不存在");
                url = "/error/lcerror";
                return url;
            }
            model.addAttribute("project", project);
        }


        //流程类型  监发三签等
        BaseDict lctype = DictUtil.getDictByCode(DictTypes.LCTYPE, affairCase.getLcType());

        //项目类型 监理 供需
        BaseDict ywtype = DictUtil.getDictByCode(DictTypes.APTYPE, affairCase.getApplicantType());

        model.addAttribute("affairCase", affairCase);
        model.addAttribute("file", file);

        model.addAttribute("fquser", user);
        model.addAttribute("lctype", lctype);
        model.addAttribute("ywtype", ywtype);
        model.addAttribute("taskId", taskId);
        model.addAttribute("taskName", taskName);
        // 只有代办页签的详情页面有 审批按钮
        String lc_type = affairCase.getLcType();
        //代办事项
        if ("1".equals(yqType)) {
            if("003".equals(applicantType)){
                doZxcheck (  file, taskName, lc_type, model);
            } else if("004".equals(applicantType)){
                doJccheck (  file, taskName, lc_type, model);
            }else{
                doJlcheck (  file, taskName, lc_type, model);
            }

        } else if ("4".equals(yqType)) {
            /*我发起的流程  可以撤销*/
            AffairRecord affairRecord = new AffairRecord();
            affairRecord.setProcessInstanceId(affairCase.getProcessInstanceId());
            Integer countlcre = affairRecordService.selectCount(affairRecord);
            if (countlcre < 2) {
                model.addAttribute("iscx", '1');
            }
        }

        return url;
    }

    public  void doZxcheck (SupervisorFile  file,String taskName,String lc_type,Model model) throws  Exception{
        //显示 审核 驳回 按钮
        model.addAttribute("lc_type", '1');
        if ("归档".equals(taskName)) {
            //显示归档按钮
            model.addAttribute("lc_type", '3');
        }

    }


    public  void doJccheck (SupervisorFile  file,String taskName,String lc_type,Model model) throws  Exception{
        //显示 审核 驳回 按钮
        model.addAttribute("lc_type", '1');
        if ("归档".equals(taskName)) {
            //显示归档按钮
            model.addAttribute("lc_type", '3');
        }

    }
    /**
    * @Author:zhaoyongke
    * @Description:
    * @param file
    * @param taskName
    * @param lc_type
    * @param model
    * @Date:11:18 2021/6/30
    */
    public  void doJlcheck (SupervisorFile  file,String taskName,String lc_type,Model model) throws  Exception{


        //显示 审核 驳回 按钮
        model.addAttribute("lc_type", '1');
        /**/
        if ("003".equals(lc_type) || "004".equals(lc_type) || "005".equals(lc_type)) {
            if ("归档".equals(taskName)) {
                //显示归档按钮
                model.addAttribute("lc_type", '3');
            }
        }
        /*获取当前用户的角色*/
        String roleName = supervisorProjectService.getUserRole(file.getId());
        /*签字 盖章 按钮的控制 */
        HashMap mapoper = supervisorFileService.getOperByRole(roleName, file.getId());
        if ("xmjl".equals(roleName)) {
            /*如果是项目经理角色，判断业主单位是否需要盖章  如果需要 则由 项目经理代理 业主单位盖章*/
            HashMap mapoperyz = supervisorFileService.getOperByRole("yz", file.getId());
            String yzoper = mapoperyz.get("oper") + "";
            if (StringUtil.isNotBlank(yzoper) && !"null".equals(yzoper)) {
                // 1a 只需要签字（文档右上角）  2a 只需要 盖章（封皮）  3a 盖章和签字分开（签字 右上角  盖章 封面）  4a  盖章和签字合并（表格中）
                //  5a 业主单位在盖章位置签字 项目经理上传图片后盖章
                if ("5a".equals(yzoper)) {
                    model.addAttribute("isyzqz", '1');
                }
            }
        }
        String oper = mapoper.get("oper") + "";

        if (StringUtil.isNotBlank(oper)) {
            switch (oper) {
                case "1a":
                    /*只是需要签字的 第一种形式(右上角 文字替换)*/
                    model.addAttribute("qz", '1');
                    model.addAttribute("isqz", '1');
                    break;
                case "2a":
                    /*只是需要盖章 第一种形式（盖章到封面）*/
                    model.addAttribute("gz", '1');
                    break;
                case "3a":
                    /*盖章和签字 分开*/
                    model.addAttribute("gz", '1');
                    model.addAttribute("isqz", '1');
                    break;
                case "4a":
                    /*盖章和签字 合并*/
                    model.addAttribute("gz", '1');
                    model.addAttribute("isqz", '1');
                    break;
                case "5a":
                    /*业主只是签字 由项目经理盖章*/
                    model.addAttribute("qz", '1');
                    model.addAttribute("isqz", '1');
                    break;
                case "6a":
                    /*表格中只是签字*/
                    model.addAttribute("qz", '1');
                    model.addAttribute("isqz", '1');
                    break;
                case "7a":
                    /*表格中只是盖章*/
                    model.addAttribute("gz", '1');
                    break;
                default:
                    break;
            }

        }

    }

    /**
     * @param dto
     * @param model
     * @Author:zhaoyongke
     * @Description: 消息通知 详情
     * @Date:9:23 2021/1/18
     */
    @GetMapping("noticeDetail")
    public String updateNoticeDetail(AffairCaseDTO dto, Model model) {
        String noticeId = dto.getCaseId();
        ProjectNotice notice = projectNoticeServie.selectByPrimaryKey(noticeId);
        /*是否查看过 1 已经查看 0  未查看*/
        notice.setIsView("1");
        notice.setModifyBy(CommonUtil.getUserId());
        notice.setModifyDate(DateUtil.getCurrentDateString());
        projectNoticeServie.updateByPrimaryKey(notice);
        String linkId = notice.getLinkId();
        /*消息类型   001 账号通知  002 流程进展 */
        String noticeType = notice.getNoticeType();
        if ("001".equals(noticeType)) {
            /*账号*/
            viewNoticeZh(linkId, model);
            model.addAttribute("dto", notice);
            return "/act/supervisor/zhNoticeDetail";
        } else if ("002".equals(noticeType)) {
            /*流程进展*/
            AffairCase affairCase = affairCaseService.selectByPrimaryKey(linkId);
            AffairCaseDTO affairCaseDTO = new AffairCaseDTO();
            BeanUtils.copyProperties(affairCase, affairCaseDTO);
            affairCaseDTO.setLcType("0");
            String url = null;
            try {
                url = viewLcDetail(affairCaseDTO, model);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (StringUtil.isNotBlank(url)) {
                return url;
            } else {
                return "/act/supervisor/processCheckDetail";
            }
        }else if("111".equals(noticeType) ||  "110".equals(noticeType) ||  "112".equals(noticeType)||  "113".equals(noticeType)||  "114".equals(noticeType)){
            String title = notice.getTitle();
            model.addAttribute("message",title);
            // 个人信息审核通过通知
            return "/act/supervisor/checkNoticeDetail";
        }
        return "/act/supervisor/zhNoticeDetail";

    }

    /**
     * @param linkId
     * @param model
     * @Author:zhaoyongke
     * @Description:消息查看---账号查看
     * @Date:13:58 2021/1/22
     */
    public void viewNoticeZh(String linkId, Model model) {
        SupervisorProject project = supervisorProjectService.selectByPrimaryKey(linkId);
        /*查询甲方账号*/
        ProjectLeaderDTO projectLeaderdto = new ProjectLeaderDTO();
        projectLeaderdto.setSupervisorProjectId(linkId);
        List<ProjectLeaderDTO> listleader = projectLeaderService.selectProjectLeaderList(projectLeaderdto);
        List<JSONObject> leader = new ArrayList<>();
        //查询业主管理员账号:
        List<SysUserDTO> sysUserDTOS = sysUserService.selectProjectAdmin(linkId);
        if (sysUserDTOS != null) {
            if(sysUserDTOS.size()>0){
                SysUserDTO admin = sysUserDTOS.get(0);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("realname", "管理员姓名：" + admin.getRealName());
                jsonObject.put("username", "用户名：" + admin.getUsername());
                jsonObject.put("companyname", "单位名称：" + admin.getCompanyName());
                jsonObject.put("password", "密码：12345678");
                leader.add(jsonObject);
            }

        }
        for (int i = 0; i < listleader.size(); i++) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("realname", "负责人姓名：" + listleader.get(i).getRealName());
            jsonObject.put("username", "用户名：" + listleader.get(i).getUsername());
            jsonObject.put("companyname", "单位名称：" + listleader.get(i).getCompanyName());
            jsonObject.put("password", "密码：12345678");
            leader.add(jsonObject);
        }
        List<JSONObject> cjlist = new ArrayList<>();
        ProjectUnitConstructionDTO unitConstructiondto = new ProjectUnitConstructionDTO();
        unitConstructiondto.setSupervisorProjectId(linkId);
        List<ProjectUnitConstructionDTO> listcj = projectUnitConstructionService.selectProjectUnitList(unitConstructiondto);
        for (int i = 0; i < listcj.size(); i++) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("realname", "负责人姓名：" + listcj.get(i).getRealName());
            jsonObject.put("username", "用户名：" + listcj.get(i).getUsername());
            jsonObject.put("companyname", "单位名称：" + listcj.get(i).getCompanyName());
            jsonObject.put("password", "密码：12345678");
            cjlist.add(jsonObject);
        }

        model.addAttribute("pro", project);
        model.addAttribute("leaderlist", leader);
        model.addAttribute("cjlist", cjlist);
        model.addAttribute("linkid", "linkId");
    }


    /**
     * @param dto
     * @param request
     * @Author:zhaoyongke
     * @Description: 查询流程记录
     * @Date:13:32 2020/12/11
     */
    @GetMapping(value = "queryLcRecord")
    @ResponseBody
    public JsonUtil queryLcRecord(AffairCaseDTO dto, HttpServletRequest request) {
        JsonUtil jsonUtil = new JsonUtil();
        String caseId = dto.getCaseId();
        if (StringUtil.isBlank(caseId)) {
            jsonUtil.setFlag(false);
            jsonUtil.setMsg("查询流程记录失败！");
            return jsonUtil;
        }
        // 查询流程记录表
        AffairRecordDTO recorddto = new AffairRecordDTO();
        recorddto.setYwId(dto.getCaseId());
        List<AffairRecordDTO> listRecord = affairRecordService.selectRecord(recorddto);
        for (int i = 0; i < listRecord.size(); i++) {
            if (StringUtil.isBlank(listRecord.get(i).getRemark())) {
                listRecord.get(i).setRemark("");
            }

        }
        jsonUtil.setFlag(true);
        jsonUtil.setData(listRecord);
        return jsonUtil;
    }


    /**
     * @param dto
     * @Author:zhaoyongke
     * @Description:启动流程方法
     * @Date:14:49 2020/12/7
     */
    @RequestMapping(value = "/updateStartLc", method = RequestMethod.POST)
    @ResponseBody
    public JsonUtil updateStartLc(SupervisorProjectDTO dto) {
        JsonUtil re = new JsonUtil();
        // 获取流程类型
        String lcType = dto.getType();
        // 文件id
        String businessId = dto.getFileId();
        SupervisorFile file = supervisorFileService.selectByPrimaryKey(businessId);
        String lcStatus = file.getLcStatus();
        //项目id
        String projectId = dto.getProjectId();
        // 文件名称
        String fileName = dto.getFileName();
        // 选择的业主userId（监发两签 监发三签 需要选择业主单位）
        String yzUserId = dto.getYzUserId();
        //选择的承建单位userId(监发三签 )
        String cjUserId = dto.getCjUserId();
        String fbId = dto.getFbId();// 分包Id
        //需要分包编号 确认业主负责人人（承发三签）
        String fbCode = "";
        try {
            if ("005".equals(lcType)) {
                ProjectContract contract = projectContractService.selectByPrimaryKey(fbId);
                fbCode = contract.getCode();
            }
            // 获取流程字典
            BaseDict AoBaseDict = DictUtil.getDictByCode(DictTypes.LCTYPE, lcType);
            /*流程名称*/
            String lcName = AoBaseDict.getBadtName();
            String roleName = supervisorProjectService.getUserRole(businessId);
            if (StringUtil.isBlank(roleName)) {
                re.setFlag(false);
                re.setMsg("您没有权限发起流程");
                return re;
            } else {
                /*001 审批 002 审核 003 监发两签 004 监发三签  005 承发三签字*/
                //查询流程状态,根据不同的流程类型判断:
                if (StringUtils.isNotBlank(lcStatus)
                        && (
                        ("2".equals(lcStatus) && ("001".equals(lcType) || "002".equals(lcType)))
                                ||
                                ("5".equals(lcStatus) && ("003".equals(lcType) || "004".equals(lcType) || "005".equals(lcType)))

                )
                ) {
                    re.setFlag(false);
                    re.setMsg("审核已通过,不允许操作");
                    return re;
                }
                if ("xmjl".equals(roleName)) {
                    if ("005".equals(lcType)) {
                        re.setFlag(false);
                        re.setMsg("" + lcName + "流程应由承建单位发起");
                        return re;
                    }
                } else if ("yz".equals(roleName)) {
                    re.setFlag(false);
                    re.setMsg("您没有权限发起流程");
                    return re;
                } else if ("cj".equals(roleName)) {
                    if (!"005".equals(lcType)) {
                        re.setFlag(false);
                        re.setMsg("您没有权限发起" + lcName + "流程");
                        return re;
                    }
                }

            }
            SupervisorProject project = supervisorProjectService.selectByPrimaryKey(projectId);

            if ("1".equals(lcStatus) || "4".equals(lcStatus)) {
                re.setFlag(false);
                re.setMsg("流程正在进行，不允许" + lcName + "");
                return re;
            }
            updateStartLcByType(file, project, lcType, fileName, yzUserId, cjUserId, fbCode);
            re.setFlag(true);
            re.setMsg("流程发起成功");
        } catch (Exception e) {
            re.setMsg("操作失败：" + e.getMessage());
            re.setFlag(false);
            e.printStackTrace();
        }
        return re;
    }


    @RequestMapping(value = "/updateStartLcZx", method = RequestMethod.POST)
    @ResponseBody
    public JsonUtil updateStartLcZx(ZxProjectDTO dto) {
        JsonUtil re = new JsonUtil();
        // 获取流程类型
        String lcType = dto.getType();
        // 文件id
        String businessId = dto.getFileId();
        SupervisorFile file = supervisorFileService.selectByPrimaryKey(businessId);
        String lcStatus = file.getLcStatus();
        //项目id
        String projectId = dto.getProjectId();
        // 文件名称
        String fileName = dto.getFileName();
        String yzUserId = dto.getYzUserId();
        String fbCode = "";
        try {
            // 获取流程字典
            BaseDict AoBaseDict = DictUtil.getDictByCode(DictTypes.LCTYPE, lcType);
            /*流程名称*/
            String lcName = AoBaseDict.getBadtName();
            String roleName = "";

            /*010 部门审核 011 审核 003 监发两签 004 监发三签  005 承发三签字*/
            //查询流程状态,根据不同的流程类型判断:
            if (StringUtils.isNotBlank(lcStatus) && ("2".equals(lcStatus) && ("010".equals(lcType) || "011".equals(lcType) || "012".equals(lcType)  ))) {
                re.setFlag(false);
                re.setMsg("审核已通过,不允许操作");
                return re;
            }
            ZxProject  project = zxProjectService.selectByPrimaryKey(projectId);
            if ("1".equals(lcStatus) || "4".equals(lcStatus)) {
                re.setFlag(false);
                re.setMsg("流程正在进行，不允许" + lcName + "");
                return re;
            }
            updateStartLcByTypeZx(file, project, lcType, fileName,yzUserId);
        } catch (Exception e) {
            re.setMsg("操作失败" + e.getMessage());
            re.setFlag(false);
            e.printStackTrace();
        }
        re.setFlag(true);
        re.setMsg("流程发起成功");
        return re;


    }

    /**
    * @Author:zhaoyongke
    * @Description:  检测启动流程
    * @param dto
    * @Date:15:42 2021/7/20
    */
    @RequestMapping(value = "/updateStartLcJc", method = RequestMethod.POST)
    @ResponseBody
    public JsonUtil updateStartLcJc(ZxProjectDTO dto) {
        JsonUtil re = new JsonUtil();
        // 获取流程类型
        String lcType = dto.getType();
        // 文件id
        String businessId = dto.getFileId();
        SupervisorFile file = supervisorFileService.selectByPrimaryKey(businessId);
        String lcStatus = file.getLcStatus();
        //项目id
        String projectId = dto.getProjectId();
        // 文件名称
        String fileName = dto.getFileName();
        String yzUserId = dto.getYzUserId();
        String fbCode = "";
        try {
            // 获取流程字典
            BaseDict AoBaseDict = DictUtil.getDictByCode(DictTypes.LCTYPE, lcType);
            /*流程名称*/
            String lcName = AoBaseDict.getBadtName();
            String roleName = "";

            /*014 检发两签 015 检测审核   016  检测审批  017 部门审核   */
            //查询流程状态,根据不同的流程类型判断:
            if (StringUtils.isNotBlank(lcStatus) && ("2".equals(lcStatus) && ("015".equals(lcType) || "016".equals(lcType) || "017".equals(lcType)  ))) {
                re.setFlag(false);
                re.setMsg("审核已通过,不允许操作");
                return re;
            }


            JcProject project = jcProjectService.selectByPrimaryKey(projectId);
            if ("1".equals(lcStatus) || "4".equals(lcStatus)) {
                re.setFlag(false);
                re.setMsg("流程正在进行，不允许" + lcName + "");
                return re;
            }
            updateStartLcByTypeJc(file, project, lcType, fileName,yzUserId);
        } catch (Exception e) {
            re.setMsg("操作失败" + e.getMessage());
            re.setFlag(false);
            e.printStackTrace();
        }
        re.setFlag(true);
        re.setMsg("流程发起成功");
        return re;


    }



    /**
     * @param dto
     * @Author:zhaoyongke
     * @Description:流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
     * @Date:11:50 2020/12/8
     */
    @RequestMapping(value = "/updateCheckJlNB", method = RequestMethod.POST)
    @ResponseBody
    public JsonUtil updateCheckJlNB(AffairCaseDTO dto) {
        JsonUtil re = new JsonUtil();
        try {
            Subject sub = SecurityUtils.getSubject();
            CurrentUser currentUser = (CurrentUser) sub.getPrincipal();
            String userid = currentUser.getId();
            //流程变量
            Map<String, Object> variables = new HashMap<String, Object>();
            //流程实例id
            String processInstanceId = dto.getProcessInstanceId();
            // caseId
            String caseId = dto.getCaseId();
            // 任务id
            String taskId = dto.getTaskId();
            // 业务表id
            String businessId = dto.getBusinessId();
            // 审核备注
            String remark = dto.getRemark();
            // 审核状态
            String checkStatus = dto.getCheckStatus();
            // 任务名称
            String taskName = dto.getTaskName();

            SupervisorFile file = new SupervisorFile();
            file.setId(businessId);
            file = supervisorFileService.selectByPrimaryKey(file);
            String fileType = file.getType();
            AffairCase affairCase = new AffairCase();
            affairCase.setCaseId(caseId);
            affairCase = affairCaseService.selectByPrimaryKey(affairCase);
            String applicantType = affairCase.getApplicantType();
            ZxProject zxproject=null;
            SupervisorProject  project=null;
            JcProject jcproject=null;
            if("003".equals(applicantType)){
                zxproject = new ZxProject();
                zxproject.setId(file.getProjectId());
                zxproject = zxProjectService.selectByPrimaryKey(zxproject);
            }else if("004".equals(applicantType)){
                jcproject=new JcProject();
                jcproject.setId(file.getProjectId());
                jcproject = jcProjectService.selectByPrimaryKey(jcproject);
            }else{
                 project = new SupervisorProject();
                 project.setId(file.getProjectId());
                 project = supervisorProjectService.selectByPrimaryKey(project);
            }


            //获取里程类型
            String lcType = affairCase.getLcType();
            JSONObject json = new JSONObject();
            // 环节名称
            String hjName = "";
            Boolean isfinish = false;
            if ("4".equals(checkStatus)) {
                String restr = updateCancle(lcType, processInstanceId, file);
                if (StringUtil.isNotBlank(restr)) {
                    re.setFlag(false);
                    re.setMsg(restr);
                    return re;
                } else {
                    /*撤销成功插入记录*/
                    addAffairCaseRecord(caseId, "001", "撤回", checkStatus, remark, taskId, processInstanceId);
                    re.setFlag(true);
                    re.setMsg("撤销成功");
                    return re;
                }

            }
            switch (lcType) {
                case "001":
                    //监理内部审批流程--项目经理发起----总监理工程师审核----技术负责人审核
                    json = updateJlnbspLc(userid, checkStatus, variables, project, businessId, affairCase, taskName);
                    break;
                case "002":
                    //监理内部审核流程--项目经理发起----总监理工程师审核
                    json = updateJlnbshLc(userid, checkStatus, variables, project, businessId, affairCase);
                    break;
                case "003":
                    //监发两签  项目经理---（监理单位+业主单位）---项目经理归档
                    json = updateJflq(userid, checkStatus, variables, project, businessId, affairCase, taskName);
                    break;
                case "004":
                    //监发三签  项目经理---（监理单位+业主单位+承建单位）---项目经理归档
                    json = updateJfsq(userid, checkStatus, variables, project, businessId, affairCase, taskName);
                    break;
                case "005":
                    //承发三签  承建单位---（监理单位+业主单位+承建单位）---项目经理归档
                    json = updateCfsq(userid, checkStatus, variables, project, businessId, fileType, affairCase, taskName);
                    break;
                case "006":
                    //部门项目经理审核
                    json = updateDeptCheck(userid, checkStatus, variables, project, businessId, affairCase);
                    break;
                case "010":
                    //部门项目经理审核--咨询
                    json = updateDeptCheckZx(userid, checkStatus, variables, zxproject, businessId, affairCase);
                    break;
                case "011":
                    //内部审核--咨询
                    json = updateJlnbshLcZx(userid, checkStatus, variables, zxproject, businessId, affairCase);
                case "012":
                    //咨询内部审批流程--项目经理发起----行业负责人审核----技术负责人审核
                    json = updateJlnbspLcZx(userid, checkStatus, variables, zxproject, businessId, affairCase, taskName);
                    break;
                case "013":
                    //咨发两签----项目经理发起---页面单位
                    json = updateZflqZx(userid, checkStatus, variables, zxproject, businessId, affairCase, taskName);
                    break;
                case "017":
                    //部门项目经理审核--检测
                    json = updateDeptCheckJc(userid, checkStatus, variables, jcproject, businessId, affairCase);
                    break;
                case "015":
                    //审核--检测
                    json = updateJlnbshLcJc(userid, checkStatus, variables, jcproject, businessId, affairCase);
                    break;
                case "016":
                    //检测内部审批流程--项目经理发起-----技术负责人审核----授权签字人审核-
                    json = updateJlnbspLcJc(userid, checkStatus, variables, jcproject, businessId, affairCase, taskName);
                    break;
                case "014":
                    //检发两签----项目经理发起---业主单位审核
                    json = updateJflqJz(userid, checkStatus, variables, jcproject, businessId, affairCase, taskName);
                    break;
                default:
            }
            /*发送流程 某某项目流程新进展，请及时查看  进展通知*/
            /*审核人不是发起人，则给流程发起人发送消息通知*/
            String sqUserId = affairCase.getApplicantId();
            if (!userid.equals(sqUserId)) {

                if("003".equals(applicantType)){
                    sendNoticeZx(affairCase, zxproject);
                }else if("004".equals(applicantType)){
                    sendNoticeJc(affairCase, jcproject);
                }else{
                    sendNotice(affairCase, project);
                }

            }
            if ("003".equals(lcType) || "004".equals(lcType) || "005".equals(lcType)|| "013".equals(lcType)|| "014".equals(lcType)) {
                updateFinishWb(json, checkStatus, affairCase, variables, businessId, taskId, isfinish);
            } else {
                workflowService.completeTask(taskId, false, variables);
            }
            //插入流程记录表
            hjName = json.get("hjname") + "";
            String record = addAffairCaseRecord(caseId, applicantType, hjName, checkStatus, remark, taskId, processInstanceId);
            if (json.get("isfinish") != null) {
                isfinish = (Boolean) json.get("isfinish");
            }
            //更新AffirCase
            updateAffirCase(affairCase, isfinish, record, checkStatus, remark);

        } catch (Exception e) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            e.printStackTrace();
            re.setMsg("操作失败" + e.getMessage());
            re.setFlag(false);
            return re;
        }
        re.setFlag(true);
        re.setMsg("操作成功");
        return re;
    }

    /**
     * @param dto
     * @Author:zhaoyongke
     * @Description:供需 项目审核
     * @Date:17:29 2021/3/29
     */
    @RequestMapping(value = "/updateCheckGxCheck", method = RequestMethod.POST)
    @ResponseBody
    public JsonUtil updateCheckGxCheck(AffairCaseDTO dto) {
        JsonUtil re = new JsonUtil();
        try {
            Subject sub = SecurityUtils.getSubject();
            CurrentUser currentUser = (CurrentUser) sub.getPrincipal();
            String userid = currentUser.getId();
            //流程变量
            Map<String, Object> variables = new HashMap<String, Object>();
            //流程实例id
            String processInstanceId = dto.getProcessInstanceId();
            // caseId
            String caseId = dto.getCaseId();
            // 任务id
            String taskId = dto.getTaskId();
            // 业务表id
            String businessId = dto.getBusinessId();
            // 审核备注
            String remark = dto.getRemark();
            // 审核状态
            String checkStatus = dto.getCheckStatus();
            // 任务名称
            String taskName = dto.getTaskName();
            SupplierProject project = supplierProjectManagerService.selectByPrimaryKey(businessId);
            // 项目名称 001 已保存 002 待审核 003 已驳回 004 已结束 005 已撤销  006 已发布
            String status = project.getStatus();
            String text="5555555555555check方法保存之前======";
            supervisorFileTempService.insertTolalLog("ADDSuTemp",text,project.getSupProjectId());
            log.info("进入111111111111111111111111111111");
            if ("006".equals(status)) {
                log.info("进入11110000000000000000000000006");
                //提交后从临时文件表 移动到正式文件表中
                String copyZskUrl = supervisorFileTempService.getCopyZskUrl(project);
                SupervisorFileTemp temp=new SupervisorFileTemp();
                temp.setLinkId(project.getSupProjectId());
                List<SupervisorFileTemp> selectfilelist = supervisorFileTempService.select(temp);
                supervisorFileTempService.updateCopyFileToZsk( copyZskUrl,project,selectfilelist);
                project.setZskurl(copyZskUrl);
                affairService.updateGxChangeProject(checkStatus, project, "001");
            } else {
                log.info("进入11110000000000000000000000007777777777777777777");
                if ("2".equals(checkStatus)) {
                    log.info("进入1111000000000000000000000000888888888888888888888");
                    //提交后从临时文件表 移动到正式文件表中
                    String copyZskUrl = supervisorFileTempService.getCopyZskUrl(project);
                    SupervisorFileTemp temp=new SupervisorFileTemp();
                    temp.setLinkId(project.getSupProjectId());
                    List<SupervisorFileTemp> selectfilelist = supervisorFileTempService.select(temp);
                    supervisorFileTempService.updateCopyFileToZsk( copyZskUrl,project,selectfilelist);
                    project.setZskurl(copyZskUrl);
                    project.setStatus("006");//已发布
                    project.setPublishDate(DateUtil.getCurrentDateString());
                } else {
                    project.setStatus("003");//已驳回

                }
            }
            project.setCheckStatus(checkStatus);
            project.setCheckRemark(remark);
            String currentDateString = DateUtil.getCurrentDateString();
            project.setCheckDate(currentDateString);
            project.setCheckBy(CommonUtil.getUserId());
            supplierProjectManagerService.updateByPrimaryKey(project);
            AffairCase affairCase = new AffairCase();
            affairCase.setCaseId(caseId);
            affairCase = affairCaseService.selectByPrimaryKey(affairCase);
            workflowService.completeTask(taskId, false, variables);
            String record = addAffairCaseRecord(caseId, "002", "发布审核", checkStatus, remark, taskId, processInstanceId);
            //更新AffirCase
            updateAffirCase(affairCase, true, record, checkStatus, remark);
            // 给发布人消息提醒
            sendNoticeCheckGx(affairCase,project,checkStatus);
            //给审核人消息提醒
            //sendNoticeReviewer(affairCase,project,checkStatus);
            //20220230 隐藏
//            List<String> ids = sysUserService.selectUserIdListForPushMsg(CommonUtil.getUserId());
//            for (String id : ids) {
//                affairCase = new AffairCase();
//                affairCase.setApplicantId(id);
//                sendNoticeReviewer(affairCase,project,checkStatus);
//            }

            String aftertext="5555555555555check方法保存之后=========";
            supervisorFileTempService.insertTolalLog("ADDSuTemp",aftertext,project.getSupProjectId());

        } catch (Exception e) {
            System.out.println("操作失败" + e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            e.printStackTrace();

            re.setMsg("操作失败" + e.getMessage());
            re.setFlag(false);
            return re;
        }
        re.setFlag(true);
        re.setMsg("操作成功");
        return re;


    }

   /**
   * @Author:zhaoyongke
   * @Description:项目审核通过 或 驳回 消息提醒
   * @param affairCase
    * @param project
   * @Date:17:21 2021/9/6
   */
    public void sendNoticeCheckGx(AffairCase affairCase, SupplierProject project,String  checkStatus) {
        String checkresult="";
        if("2".equals(checkStatus)){
            checkresult="通过";
        }else{
            checkresult="不通过";
        }
        ProjectNotice notice = new ProjectNotice();
        notice.setLinkId(project.getSupProjectId());
        notice.setIsView("0");
        notice.setSendTo(affairCase.getApplicantId());
        notice.setTitle(project.getProjectName() + "项目审核"+checkresult+"，请及时查看");
        notice.setNoticeType("110");//通知类型 账号通知 001  002 流程进展通知
        notice.setApplicantType("002");// 供需
        projectNoticeServie.insertSelective(notice);
    }


    /**
     *
     * @param affairCase
     * @param project
     * @param checkStatus
     */
    public void sendNoticeReviewer(AffairCase affairCase, SupplierProject project, String checkStatus){
        String checkresult="";
        if("2".equals(checkStatus)){
            checkresult="通过";
        }else{
            checkresult="不通过";
        }
        ProjectNotice notice = new ProjectNotice();
        notice.setLinkId(project.getSupProjectId());
        notice.setIsView("0");
        notice.setSendTo(affairCase.getApplicantId());
        notice.setTitle(project.getProjectName() + "项目审核"+checkresult+"，请及时查看");
        notice.setNoticeType("112");//通知类型 账号通知 001  002 流程进展通知
        notice.setApplicantType("002");// 供需
        projectNoticeServie.insertSelective(notice);
    }



    /**
     * @param checkStatus
     * @param affairCase
     * @param variables
     * @param businessId
     * @param taskId
     * @param isfinish
     * @Author:zhaoyongke
     * @Description: 处理外部流程完成任务
     * @Date:17:46 2021/1/25
     */
    public void updateFinishWb(JSONObject jsonObject, String checkStatus, AffairCase affairCase, Map<String, Object> variables, String businessId, String taskId, Boolean isfinish) {
        if ("3".equals(checkStatus)) {
            variables.put("check", "-1");
            /*处理  003  004  005 会签  一方 驳回 全部任务结束*/
            List<Task> assigneeList = taskService.createTaskQuery().processInstanceId(affairCase.getProcessInstanceId()).list();
            for (Task task : assigneeList) {
                workflowService.completeTask(task.getId(), false, variables);
            }
            /*审核不通过*/
            updateFileStatus(businessId, "6");
            jsonObject.put("isfinish", true);

        } else {
            variables.put("check", "1");
            workflowService.completeTask(taskId, false, variables);
        }

    }

    /**
     * @param lcType
     * @param processInstanceId
     * @param file
     * @Author:zhaoyongke
     * @Description:
     * @Date:17:44 2021/1/25
     */
    public String updateCancle(String lcType, String processInstanceId, SupervisorFile file) {
        String str = "";
        /*判断下一节点有没有审核*/
        AffairRecord affairRecord = new AffairRecord();
        affairRecord.setProcessInstanceId(processInstanceId);
        Integer countlcre = affairRecordService.selectCount(affairRecord);
        if (countlcre > 1) {
            str = "该流程下一节点已经被审核，不允许撤回";
            return str;
        }
        /*撤回操作*/
        runtimeService.deleteProcessInstance(processInstanceId, "撤销");
        /*修改业务表状态*/
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        // 不管流程之前有没有 内部流程，统一处理成 2
        if ("003".equals(lcType) || "004".equals(lcType) || "005".equals(lcType)) {
            file.setLcStatus("2");
        } else {
            file.setLcStatus("0");
        }
        supervisorFileService.updateByPrimaryKey(file);
        // 保存流程记录
        return str;
    }

    /**
     * @param affairCase
     * @param project
     * @Author:zhaoyongke
     * @Description: 发送通知
     * @Date:13:28 2021/1/22
     */
    public void sendNotice(AffairCase affairCase, SupervisorProject project) {
        ProjectNotice notice = new ProjectNotice();
        notice.setLinkId(affairCase.getCaseId());
        notice.setIsView("0");
        notice.setSendTo(affairCase.getApplicantId());
        notice.setTitle(project.getProjectName() + "项目流程有新进展，请及时查看");
        notice.setNoticeType("002");//通知类型 账号通知 001  002 流程进展通知
        notice.setApplicantType("001");// 监理
        projectNoticeServie.insertSelective(notice);
    }


    /**
     * @param affairCase
     * @param project
     * @Author:zhaoyongke
     * @Description: 发送通知
     * @Date:13:28 2021/1/22
     */
    public void sendNoticeZx(AffairCase affairCase, ZxProject project) {
        ProjectNotice notice = new ProjectNotice();
        notice.setLinkId(affairCase.getCaseId());
        notice.setIsView("0");
        notice.setSendTo(affairCase.getApplicantId());
        notice.setTitle(project.getProjectName() + "项目流程有新进展，请及时查看");
        notice.setNoticeType("002");//通知类型 账号通知 001  002 流程进展通知
        notice.setApplicantType("003");//咨询
        projectNoticeServie.insertSelective(notice);
    }

    /**
     * @param affairCase
     * @param project
     * @Author:zhaoyongke
     * @Description: 发送通知
     * @Date:13:28 2021/1/22
     */
    public void sendNoticeJc(AffairCase affairCase, JcProject project) {
        ProjectNotice notice = new ProjectNotice();
        notice.setLinkId(affairCase.getCaseId());
        notice.setIsView("0");
        notice.setSendTo(affairCase.getApplicantId());
        notice.setTitle(project.getProjectName() + "项目流程有新进展，请及时查看");
        notice.setNoticeType("002");//通知类型 账号通知 001  002 流程进展通知
        notice.setApplicantType("004");//003 咨询  004 检测
        projectNoticeServie.insertSelective(notice);
    }

    /**
     * @param file
     * @param project
     * @param lcType
     * @param fileName
     * @Author:zhaoyongke
     * @Description: 根据类型启动流程
     * @Date:19:35 2020/12/7
     */
    public void updateStartLcByTypeJc(SupervisorFile file, JcProject project, String lcType, String fileName,String yzUserId) throws Exception {
        // 业务类型 001 监理业务  002 咨询 003 检测
        String ywType = WorkflowService.JCTYPE;
        // 流程类型 监发三签 两签等
        String LcType = "";
        // 流程启动key
        String key = "";
        switch (lcType) {
            case "017":
                key = WorkflowService.DEPTCHECK;
                LcType = WorkflowService.LCTYPE017;
                updateStartDeptshJc(file, key, project, fileName, ywType, LcType);
                break;
            case "016":
                // 审批
                key = WorkflowService.JCNBSP;
                LcType = WorkflowService.LCTYPE016;
                updateStartJlnbshJc(file, key, project, fileName, ywType, LcType);
                break;
            case "015":
                // 审核
                key = WorkflowService.JCNBSH;
                LcType = WorkflowService.LCTYPE015;
                updateStartJlnbshJc(file, key, project, fileName, ywType, LcType);
                break;
            case "014":
                // 检发两签
                key = WorkflowService.JCJFLQ001;
                LcType = WorkflowService.LCTYPE014;
                updateStartZflqJc( file,  key,  project,  fileName,  ywType,  lcType,  yzUserId);
                break;

            default:
        }
    }


    /**
     * @param file
     * @param project
     * @param lcType
     * @param fileName
     * @Author:zhaoyongke
     * @Description: 根据类型启动流程
     * @Date:19:35 2020/12/7
     */
    public void updateStartLcByTypeZx(SupervisorFile file, ZxProject project, String lcType, String fileName,String yzUserId) throws Exception {
        // 业务类型 001 监理业务  002 咨询 003 检测
        String ywType = WorkflowService.ZXTYPE;
        // 流程类型 监发三签 两签等
        String LcType = "";
        // 流程启动key
        String key = "";
        switch (lcType) {
            case "010":
                key = WorkflowService.DEPTCHECK;
                LcType = WorkflowService.LCTYPE010;
                updateStartDeptshZx(file, key, project, fileName, ywType, LcType);
                break;
            case "011":
                key = WorkflowService.ZXNBSH;
                LcType = WorkflowService.LCTYPE011;
                updateStartJlnbshZx(file, key, project, fileName, ywType, LcType);
                break;
            case "012":
                key = WorkflowService.ZXNBSP;
                LcType = WorkflowService.LCTYPE012;
                updateStartJlnbshZx(file, key, project, fileName, ywType, LcType);
                break;
            case "013":
                key = WorkflowService.ZXZFLQ001;
                LcType = WorkflowService.LCTYPE013;
                updateStartZflqZx( file,  key,  project,  fileName,  ywType,  lcType,  yzUserId);
                break;

            default:
        }
    }


    /**
     * @param file
     * @param project
     * @param lcType
     * @param fileName
     * @Author:zhaoyongke
     * @Description: 根据类型启动流程
     * @Date:19:35 2020/12/7
     */
    public void updateStartLcByType(SupervisorFile file, SupervisorProject project, String lcType, String fileName, String yzUserId, String cjUserId, String fbCode) throws Exception {
        // 业务类型 001 监理业务  002 咨询 003 检测
        String ywType = WorkflowService.JLTYPE;
        // 流程类型 监发三签 两签等
        String LcType = "";
        // 流程启动key
        String key = "";
        switch (lcType) {
            case "001":
                //监理内部审批流程--项目经理发起----总监理工程师审核----技术负责人审核
                key = WorkflowService.JLNBSP;
                LcType = WorkflowService.LCTYPE001;
                updateStartJlnbsp(file, key, project, fileName, ywType, LcType);
                break;
            case "002":
                key = WorkflowService.JLNBSH;
                LcType = WorkflowService.LCTYPE002;
                updateStartJlnbsh(file, key, project, fileName, ywType, LcType);
                break;
            case "003":
                key = WorkflowService.JLJFLQ;
                LcType = WorkflowService.LCTYPE003;
                updateStartJflq(file, key, project, fileName, ywType, LcType, yzUserId);
                break;
            case "004":
                key = WorkflowService.JLJFSQ;
                LcType = WorkflowService.LCTYPE004;
                updateStartJfsq(file, key, project, fileName, ywType, LcType, yzUserId, cjUserId);
                break;
            case "005":
                key = WorkflowService.JLCFSQ;
                LcType = WorkflowService.LCTYPE005;
                updateStartCfsq(file, key, project, fileName, ywType, LcType, fbCode);
                break;
            case "006":
                key = WorkflowService.DEPTCHECK;
                LcType = WorkflowService.LCTYPE006;
                updateStartDeptsh(file, key, project, fileName, ywType, LcType);
                break;
            default:
        }
    }

    /**
     * @param
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @Author:zhaoyongke
     * @Description: 监理内部审批流程启动
     * @Date:15:08 2020/12/7
     */
    public void updateStartJlnbsp(SupervisorFile file, String key, SupervisorProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //获取项目的总监理工程师
        String zj = project.getSupervisorEngineer();
        // 设置流程变量
        variables.put("zj", zj);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }



    public void updateStartJlnbspJc(SupervisorFile file, String key, JcProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //获取项目的行业负责人
        String hy = project.getIndustryPerson();
        // 设置流程变量
        variables.put("hy", hy);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }
    /**
     * @param
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @Author:zhaoyongke
     * @Description: 咨询内部审批流程启动
     * @Date:15:08 2020/12/7
     */
    public void updateStartJlnbspZx(SupervisorFile file, String key, ZxProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //获取项目的行业负责人
        String hy = project.getIndustryPerson();
        // 设置流程变量
        variables.put("hy", hy);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }
    /**
     * @param file
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @param lcType
     * @Author:zhaoyongke
     * @Description: 监理内部审核流程启动
     * @Date:13:40 2020/12/9
     */
    public void updateStartJlnbsh(SupervisorFile file, String key, SupervisorProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //获取项目的总监理工程师
        String zj = project.getSupervisorEngineer();
        // 设置流程变量
        variables.put("zj", zj);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }

    /**
     * @Author:zhaoyongke
     * @Description: 咨询的内部审核流程
     * @param file
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @param lcType
     * @Date:13:38 2021/6/30
     */
    public void updateStartJlnbshJc(SupervisorFile file, String key, JcProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //技术负责人审核
        String js = project.getTechnologyPerson();
        // 设置流程变量
        variables.put("js", js);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }


    /**
    * @Author:zhaoyongke
    * @Description: 咨询的内部审核流程
    * @param file
    * @param key
    * @param project
    * @param fileName
    * @param ywType
    * @param lcType
    * @Date:13:38 2021/6/30
    */
    public void updateStartJlnbshZx(SupervisorFile file, String key, ZxProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //获取项目的行业负责人
        String hy = project.getIndustryPerson();
        // 设置流程变量
        variables.put("hy", hy);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }

    public void updateStartDeptshZx(SupervisorFile file, String key, ZxProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //部门经理
        SysUserDTO sysUserDTO = new SysUserDTO();
        sysUserDTO.setUserRole("zxSoftPowershr");
        List<SysUser> sysUsers = sysUserService.getUserDicts(sysUserDTO);
        List<String> userlist = new ArrayList<>();
        for (int i = 0; i < sysUsers.size(); i++) {
            userlist.add(sysUsers.get(i).getId());
        }
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("userList", userlist);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }


    public void updateStartDeptshJc(SupervisorFile file, String key, JcProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //部门经理
        SysUserDTO sysUserDTO = new SysUserDTO();
        sysUserDTO.setUserRole("jcSoftPowershr");
        List<SysUser> sysUsers = sysUserService.getUserDicts(sysUserDTO);
        List<String> userlist = new ArrayList<>();
        for (int i = 0; i < sysUsers.size(); i++) {
            userlist.add(sysUsers.get(i).getId());
        }
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("userList", userlist);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }






    public void updateStartDeptsh(SupervisorFile file, String key, SupervisorProject project, String fileName, String ywType, String lcType) {
        String caseName = project.getProjectName() + "_" + fileName;
        //部门经理
        SysUserDTO sysUserDTO = new SysUserDTO();
        sysUserDTO.setUserRole("deptcheckperson");
        List<SysUser> sysUsers = sysUserService.getUserDicts(sysUserDTO);
        List<String> userlist = new ArrayList<>();
        for (int i = 0; i < sysUsers.size(); i++) {
            userlist.add(sysUsers.get(i).getId());
        }
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("userList", userlist);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }

    /**
     * @param file
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @param lcType
     * @param yzUserId
     * @Author:zhaoyongke
     * @Description: 监发两签  启动流程
     * @Date:16:20 2020/12/10
     */
    public void updateStartJflq(SupervisorFile file, String key, SupervisorProject project, String fileName, String ywType, String lcType, String yzUserId) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();

        List<String> listuser = StringUtil.split(yzUserId);
        //业主单位负责人 动态创建多节点
        variables.put("yzuserlist", listuser);
        //监理项目经理
        String manager = project.getProjectManagerPerson();
        variables.put("jluser", manager);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }

    /**
    * @Author:zhaoyongke
    * @Description: 检测 检发两签
    * @param file
    * @param key
    * @param project
    * @param fileName
    * @param ywType
    * @param lcType
    * @param yzUserId
    * @Date:10:27 2021/7/21
    */
    public void updateStartZflqJc(SupervisorFile file, String key, JcProject project, String fileName, String ywType, String lcType, String yzUserId) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //业主单位负责人
        variables.put("yzuser", yzUserId);
        //检测项目经理
        String manager = project.getProjectManagerPerson();
        variables.put("jcuser", manager);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }

    /**
     * @param file
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @param lcType
     * @param yzUserId
     * @Author:zhaoyongke
     * @Description: 咨发发两签  启动流程
     * @Date:16:20 2020/12/10
     */
    public void updateStartZflqZx(SupervisorFile file, String key, ZxProject project, String fileName, String ywType, String lcType, String yzUserId) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        //业主单位负责人
        variables.put("yzuser", yzUserId);
        //监理项目经理
        String manager = project.getProjectManagerPerson();
        variables.put("zxuser", manager);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }

    /**
     * @param file
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @param lcType
     * @param yzUserId
     * @param cjUserId
     * @Author:zhaoyongke
     * @Description:监发三签流程启动
     * @Date:9:33 2020/12/11
     */
    public void updateStartJfsq(SupervisorFile file, String key, SupervisorProject project, String fileName, String ywType, String lcType, String yzUserId, String cjUserId) {
        String caseName = project.getProjectName() + "_" + fileName;
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        // 获取业主单位
        List<String> yzuserlist = StringUtil.split(yzUserId);
        //业主单位负责人 动态创建多节点
        variables.put("yzuserlist", yzuserlist);
        // 获取承建单位
        List<String> cjUserIdlist = StringUtil.split(cjUserId);
        //承建单位负责人 动态创建多节点
        variables.put("cjuserlist", cjUserIdlist);
        //监理项目经理
        String manager = project.getProjectManagerPerson();
        variables.put("jluser", manager);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }

    /**
     * @param file
     * @param key
     * @param project
     * @param fileName
     * @param ywType
     * @param lcType
     * @Author:zhaoyongke
     * @Description: 承发三签
     * @Date:9:30 2020/12/12
     */
    public void updateStartCfsq(SupervisorFile file, String key, SupervisorProject project, String fileName, String ywType, String lcType, String fbCode) throws Exception {
        //流程变量
        Map<String, Object> variables = new HashMap<String, Object>();
        String caseName = project.getProjectName() + "_" + fileName;
        // 获取登录人（承建单位用户Id）
        String cjuserId = "";
        if (StringUtil.isNotBlank(fbCode)) {
            // 获取业主单位（承建单位的分包编号对应业主单位负责人确定接收人）
            ProjectUnitConstructionDTO unitConstructionDTO = new ProjectUnitConstructionDTO();
            unitConstructionDTO.setSupervisorProjectId(project.getId());
            unitConstructionDTO.setConstructionSubContractNumber(fbCode);
            List<ProjectUnitConstruction> listunit = projectUnitConstructionService.select(unitConstructionDTO);
            if (listunit.size() > 0) {
                cjuserId = listunit.get(0).getProjectManager();
            }
        }
        if (StringUtil.isBlank(cjuserId)) {
            throw new Exception("获取承建单位失败");
        }
        //承建单位负责人
        variables.put("cjuser", cjuserId);
        //监理项目经理
        String manager = project.getProjectManagerPerson();
        variables.put("jluser", manager);
        //业主单位
        String yzUserId = "";
        if (StringUtil.isNotBlank(fbCode)) {
            // 获取业主单位（承建单位的分包编号对应业主单位负责人确定接收人）
            ProjectLeaderDTO leaderDTO = new ProjectLeaderDTO();
            leaderDTO.setSupervisorProjectId(project.getId());
            leaderDTO.setLeaderFbNumber(fbCode);
            List<ProjectLeaderDTO> listleader = projectLeaderService.selectProjectLeaderList(leaderDTO);
            if (listleader.size() > 0) {
                yzUserId = listleader.get(0).getProjectLeader();
            }else{
                throw new Exception("获取业主单位失败");
            }
        }
        //业主单位负责人
        variables.put("yzuser", yzUserId);
        //(1)启动流程
        String lcdyid = workflowService.startAffairWorkflow(caseName, key, file, ywType, lcType, variables);
    }


    /**
     * @param
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @Author:zhaoyongke
     * @Description: 监理内部审批流程处理 ------审核  流程类型 001
     * @Date:14:52 2020/12/8
     */
    public JSONObject updateJlnbspLc(String userId, String checkStatus, Map<String, Object> variables, SupervisorProject project, String businessId, AffairCase affairCase, String taskName) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        if ("总监理工程师审核".equals(taskName)) {
            // 总监理工程师审核
            if ("2".equals(checkStatus)) {
                // 审核通过
                variables.put("zjchek", "1");
                //下一步技术负责人审核
                String jsuserid = project.getTechnologyPerson();
                variables.put("js", jsuserid);
            } else {
                // 审核不通过
                variables.put("zjchek", "-1");
                //流程结束  内部流程审核不通过
                updateFileStatus(businessId, "3");
                //完成
                isFinish = true;

            }
            hjName = "总监理工程师审核";
        } else if ("技术负责人审核".equals(taskName)) {
            // 技术负责人审核
            if ("2".equals(checkStatus)) {
                //流程结束 审核通过
                updateFileStatus(businessId, "2");
                //更新用章记录
                projectSealRecordService.updateSealRecord(project.getId(), businessId);
                //完成
                isFinish = true;
            } else {
                //流程结束 审核不通过
                variables.put("zjchek", "-1");
                //内部流程审核不通过
                updateFileStatus(businessId, "3");
                //完成
                isFinish = true;
            }

            hjName = "技术负责人审核";

        }
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }
    public JSONObject updateJlnbspLcJc(String userId, String checkStatus, Map<String, Object> variables, JcProject project, String businessId, AffairCase affairCase, String taskName) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        if ("技术负责人审核".equals(taskName)) {
            // 技术负责人审核
            if ("2".equals(checkStatus)) {
                // 审核通过
                variables.put("hychek", "1");
                //下一步授权签字人
                String jsuserid = project.getIndustryPerson();
                variables.put("qz", jsuserid);
            } else {
                // 审核不通过
                variables.put("hychek", "-1");
                //流程结束  内部流程审核不通过
                updateFileStatus(businessId, "3");
                //完成
                isFinish = true;

            }
            hjName = "技术负责人审核";
        } else if ("授权签字人审核".equals(taskName)) {
            // 授权签字人审核
            if ("2".equals(checkStatus)) {
                //流程结束 审核通过
                updateFileStatus(businessId, "2");
                //更新用章记录
                projectSealRecordService.updateSealRecord(project.getId(), businessId);
                //完成
                isFinish = true;
            } else {
                //流程结束 审核不通过
                variables.put("hychek", "-1");
                //内部流程审核不通过
                updateFileStatus(businessId, "3");
                //完成
                isFinish = true;
            }

            hjName = "授权签字人审核";

        }
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }

    public JSONObject updateJlnbspLcZx(String userId, String checkStatus, Map<String, Object> variables, ZxProject project, String businessId, AffairCase affairCase, String taskName) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        if ("行业负责人审核".equals(taskName)) {
            // 行业负责人审核
            if ("2".equals(checkStatus)) {
                // 审核通过
                variables.put("hychek", "1");
                //下一步技术负责人审核
                String jsuserid = project.getTechnologyPerson();
                variables.put("js", jsuserid);
            } else {
                // 审核不通过
                variables.put("hychek", "-1");
                //流程结束  内部流程审核不通过
                updateFileStatus(businessId, "3");
                //完成
                isFinish = true;

            }
            hjName = "行业负责人审核";
        } else if ("技术负责人审核".equals(taskName)) {
            // 技术负责人审核
            if ("2".equals(checkStatus)) {
                //流程结束 审核通过
                updateFileStatus(businessId, "2");
                //更新用章记录
                projectSealRecordService.updateSealRecord(project.getId(), businessId);
                //完成
                isFinish = true;
            } else {
                //流程结束 审核不通过
                variables.put("hychek", "-1");
                //内部流程审核不通过
                updateFileStatus(businessId, "3");
                //完成
                isFinish = true;
            }

            hjName = "技术负责人审核";

        }
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }




    /**
     * @param
     * @Author:zhaoyongke
     * @Description: 监发两签 提交updateJfsq
     * @Date:17:20 2020/12/10updateJfsq
     */
    public JSONObject updateJflq(String userId, String checkStatus, Map<String, Object> variables, SupervisorProject project, String businessId, AffairCase affairCase, String taskName) {

        JSONObject jsonObject = new JSONObject();
        Boolean isFinish = false;
        String hjName = taskName;

        if ("归档".equals(taskName)) {
            //流程结束  归档
            updateFileStatus(businessId, "5");
            // 完成
            isFinish = true;
        } else {
            //项目经理
            String manager = project.getProjectManagerPerson();
            variables.put("jluser", manager);
        }

        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }
    /**
     * @param
     * @Author:zhaoyongke
     * @Description: 检发两签 提交updateJfsq
     * @Date:17:20 2020/12/10updateJfsq
     */
    public JSONObject updateJflqJz(String userId, String checkStatus, Map<String, Object> variables, JcProject project, String businessId, AffairCase affairCase, String taskName) {

        JSONObject jsonObject = new JSONObject();
        Boolean isFinish = false;
        String hjName = taskName;

        if ("归档".equals(taskName)) {
            //流程结束  归档
            updateFileStatus(businessId, "5");
            // 完成
            isFinish = true;
        } else {
            //项目经理
            String manager = project.getProjectManagerPerson();
            variables.put("jcuser", manager);
        }

        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }
    /**
     * @param
     * @Author:zhaoyongke
     * @Description: 咨询发两签 提交updateJfsq
     * @Date:17:20 2020/12/10updateJfsq
     */
    public JSONObject updateZflqZx(String userId, String checkStatus, Map<String, Object> variables, ZxProject project, String businessId, AffairCase affairCase, String taskName) {

        JSONObject jsonObject = new JSONObject();
        Boolean isFinish = false;
        String hjName = taskName;

        if ("归档".equals(taskName)) {
            //流程结束  归档
            updateFileStatus(businessId, "5");
            // 完成
            isFinish = true;
        } else {
            //项目经理
            String manager = project.getProjectManagerPerson();
            variables.put("zxuser", manager);
        }

        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }

    /**
     * @param userId
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @param taskName
     * @Author:zhaoyongke
     * @Description: 监发三签
     * @Date:9:41 2020/12/11
     */
    public JSONObject updateJfsq(String userId, String checkStatus, Map<String, Object> variables, SupervisorProject project, String businessId, AffairCase affairCase, String taskName) {
        JSONObject jsonObject = new JSONObject();
        Boolean isFinish = false;
        String hjName = taskName;
        if ("归档".equals(taskName)) {
            //流程结束  归档
            updateFileStatus(businessId, "5");
            // 完成
            isFinish = true;
        } else {
            //项目经理
            String manager = project.getProjectManagerPerson();
            variables.put("jluser", manager);
        }
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;
    }

    /**
     * @param userId
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @param taskName
     * @Author:zhaoyongke
     * @Description: 承发三签审核
     * @Date:9:49 2020/12/12
     */
    public JSONObject updateCfsq(String userId, String checkStatus, Map<String, Object> variables, SupervisorProject project, String businessId, String fileType, AffairCase affairCase, String taskName) {
        JSONObject jsonObject = new JSONObject();
        Boolean isFinish = false;
        String hjName = taskName;
        if ("归档".equals(taskName)) {
            //流程结束  归档
            updateFileStatus(businessId, "5");
            // 完成
            isFinish = true;
        } else if ("监理单位签字".equals(taskName)) {
            /*根据文件类型判断 是否走总监理工程师环节 工程初验报审表   工程终验报审表 服务验收报审表   093 工程变更单  */
            if ("2".equals(checkStatus)) {
                if ("052".equals(fileType) || "059".equals(fileType) || "077".equals(fileType) || "093".equals(fileType)) {
                    // 需要总监理签字
                    String zjl = project.getSupervisorEngineer();
                    variables.put("zjluser", zjl);
                    variables.put("needzjlcheck", "1");
                } else {
                    // 不需要总监理签字
                    variables.put("needzjlcheck", "-1");
                }
            } else {
                // 不需要总监理签字
                variables.put("needzjlcheck", "-1");
            }

        }
        {
            // 其他两方签字 承建单位和业主单位审核
            if ("3".equals(checkStatus)) {
                //驳回擦作
                variables.put("needzjlcheck", "-1");
            }
        }
        //项目经理
        String manager = project.getProjectManagerPerson();
        variables.put("jluser", manager);
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;
    }

    /**
     * @param roleName
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @Author:zhaoyongke
     * @Description: 监理内部审核流程 ------审核
     * @Date:13:46 2020/12/9
     */
    public JSONObject updateJlnbshLc(String roleName, String checkStatus, Map<String, Object> variables, SupervisorProject project, String businessId, AffairCase affairCase) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        // 总监理工程师审核
        if ("2".equals(checkStatus)) {
            // 审核通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "2");
            //更新用章记录
            projectSealRecordService.updateSealRecord(project.getId(), businessId);
            // 完成
            isFinish = true;
        } else {
            // 审核不通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "3");
            // 完成
            isFinish = true;

        }
        hjName = "总监理工程师审核";
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }


    /**
     * @param roleName
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @Author:zhaoyongke
     * @Description: 检测内部审核流程 ------审核
     * @Date:13:46 2020/12/9
     */
    public JSONObject updateJlnbshLcJc(String roleName, String checkStatus, Map<String, Object> variables, JcProject project, String businessId, AffairCase affairCase) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        // 授权签字人审核
        if ("2".equals(checkStatus)) {
            // 审核通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "2");
            //更新用章记录
            projectSealRecordService.updateSealRecord(project.getId(), businessId);
            // 完成
            isFinish = true;
        } else {
            // 审核不通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "3");
            // 完成
            isFinish = true;

        }
        hjName = "技术负责人审核";
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }

    /**
     * @param roleName
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @Author:zhaoyongke
     * @Description: 监理内部审核流程 ------审核
     * @Date:13:46 2020/12/9
     */
    public JSONObject updateJlnbshLcZx(String roleName, String checkStatus, Map<String, Object> variables, ZxProject project, String businessId, AffairCase affairCase) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        // 总监理工程师审核
        if ("2".equals(checkStatus)) {
            // 审核通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "2");
            //更新用章记录
            projectSealRecordService.updateSealRecord(project.getId(), businessId);
            // 完成
            isFinish = true;
        } else {
            // 审核不通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "3");
            // 完成
            isFinish = true;

        }
        hjName = "行业负责人审核";
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }



    /**
     * @param roleName
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @Author:zhaoyongke
     * @Description: 监理内部审核流程 ------部门经理审核
     * @Date:13:46 2020/12/9
     */
    public JSONObject updateDeptCheck(String roleName, String checkStatus, Map<String, Object> variables, SupervisorProject project, String businessId, AffairCase affairCase) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        // 部门经理审核
        if ("2".equals(checkStatus)) {
            // 审核通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "2");
            //更新用章记录
            projectSealRecordService.updateSealRecord(project.getId(), businessId);
            // 完成
            isFinish = true;
        } else {
            // 审核不通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "3");
            // 完成
            isFinish = true;

        }
        hjName = "部门经理审核";
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }

    /**
     * @param roleName
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @Author:zhaoyongke
     * @Description: 监理内部审核流程 ------部门经理审核
     * @Date:13:46 2020/12/9
     */
    public JSONObject updateDeptCheckZx(String roleName, String checkStatus, Map<String, Object> variables, ZxProject project, String businessId, AffairCase affairCase) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        // 部门经理审核
        if ("2".equals(checkStatus)) {
            // 审核通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "2");
            //更新用章记录
            projectSealRecordService.updateSealRecord(project.getId(), businessId);
            // 完成
            isFinish = true;
        } else {
            // 审核不通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "3");
            // 完成
            isFinish = true;

        }
        hjName = "部门经理审核";
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }


    /**
     * @param roleName
     * @param checkStatus
     * @param variables
     * @param project
     * @param businessId
     * @param affairCase
     * @Author:zhaoyongke
     * @Description: 监理内部审核流程 ------部门经理审核
     * @Date:13:46 2020/12/9
     */
    public JSONObject updateDeptCheckJc(String roleName, String checkStatus, Map<String, Object> variables, JcProject project, String businessId, AffairCase affairCase) {
        JSONObject jsonObject = new JSONObject();
        String hjName = "";
        Boolean isFinish = false;
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        // 部门经理审核
        if ("2".equals(checkStatus)) {
            // 审核通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "2");
            //更新用章记录
            projectSealRecordService.updateSealRecord(project.getId(), businessId);
            // 完成
            isFinish = true;
        } else {
            // 审核不通过
            //流程结束  内部流程审核不通过
            updateFileStatus(businessId, "3");
            // 完成
            isFinish = true;

        }
        hjName = "部门经理审核";
        jsonObject.put("hjname", hjName);
        jsonObject.put("isfinish", isFinish);
        return jsonObject;

    }


    public String addAffairCaseRecord(String ywId, String ywType, String hjName, String checkStatus, String remark, String taskId, String processInstanceId) {
        AffairRecordDTO dto = new AffairRecordDTO();
        // 业务Id
        dto.setYwId(ywId);
        /**
         * 业务类型 001 监理系统 002 供需 0
         */
        dto.setYwType(ywType);
        //环节名称
        dto.setHjName(hjName);
        //审核状态 1 提交 2 审核通过 3 审核不通过

        dto.setCheckStatus(checkStatus);
        //备注
        dto.setRemark(remark);
        // 任务id
        dto.setTaskId(taskId);
        // 工作流实例id
        dto.setProcessInstanceId(processInstanceId);
        String recordId = workflowService.addAffairCaseRecord(dto);
        return recordId;

    }

    /**
     * @param fileId
     * @param lcstatus
     * @Author:zhaoyongke
     * @Description: 修改流程状态
     * @Date:13:20 2020/12/8
     */
    public void updateFileStatus(String fileId, String lcstatus) {
        //流程状态0 内部未发起流程1 内部进行中 2 内部流程审核通过3内部流程审核不通过4外部流程进行中5外部流程审核通过（归档）6 外部流程审核不通过
        SupervisorFile file = new SupervisorFile();
        file.setId(fileId);
        file = supervisorFileService.selectByPrimaryKey(file);
        file.setLcStatus(lcstatus);
        supervisorFileService.updateByPrimaryKey(file);
    }

    /**
     * @param affairCase
     * @Author:zhaoyongke
     * @Description: 更新affircase
     * @Date:17:01 2020/12/8
     */
    public void updateAffirCase(AffairCase affairCase, Boolean isfinsih, String recordId, String checkStatus, String remark) {
        if (isfinsih) {
            affairCase.setEndresult("1");
            affairCase.setEndTime(DateUtil.formatDate(new Date()));
            if ("3".equals(checkStatus)) {
                //审核不通过 审核备注
                affairCase.setMemo(remark);
            }
        }

        affairCase.setCurrRecordId(recordId);
        affairCaseService.updateByPrimaryKey(affairCase);
    }

    @GetMapping(value = "lcselectJsr")
    public String lcselectJsr(SupervisorProjectDTO dto, Model model) {
        // 流程类型
        String type = dto.getType();
        String projectId = dto.getProjectId();
        String fileName = dto.getFileName();//
        String fileId = dto.getFileId();
        SupervisorProject pdto = supervisorProjectService.selectByPrimaryKey(projectId);
        // 查询业主单位负责人  监发两签流程需要选择业主单位负责人
        ProjectLeaderDTO projectLeaderdto = new ProjectLeaderDTO();
        projectLeaderdto.setSupervisorProjectId(projectId);
        List<ProjectLeaderDTO> listleader = projectLeaderService.selectProjectLeaderList(projectLeaderdto);
        //根据项目Id  查询 project_admin
//        ProjectAdmin projectAdmin = new ProjectAdmin();
//        projectAdmin.setSpId(projectId);
//        List<ProjectAdmin> projectAdminList = projectAdminService.select(projectAdmin);
//        if (projectAdminList.size() > 0) {
//            ProjectAdmin projectAdmin1 = projectAdminList.get(0);
//            String userId = projectAdmin1.getUId();
//            SysUser sysUser = sysUserService.selectByPrimaryKey(userId);
//            ProjectLeaderDTO dtofz = new ProjectLeaderDTO();
//            dtofz.setRealName("管理员");
//            dtofz.setProjectLeader(userId);
//            listleader.add(dtofz);
//
//        }


        List<ProjectUnitConstructionDTO> listcj = null;
        if ("004".equals(type)) {
            // 监发三签
            //查询承建单位
            ProjectUnitConstructionDTO unitConstructiondto = new ProjectUnitConstructionDTO();
            unitConstructiondto.setSupervisorProjectId(projectId);
            listcj = projectUnitConstructionService.selectProjectUnitList(unitConstructiondto);
        }
        model.addAttribute("type", type);
        model.addAttribute("projectId", projectId);
        model.addAttribute("fileName", fileName);
        model.addAttribute("fileId", fileId);
        model.addAttribute("listleader", listleader);
        model.addAttribute("listcj", listcj);
        model.addAttribute("pdto", pdto);
        return "/act/supervisor/lcselectJsr";
    }
    /**
    * @Author:zhaoyongke
    * @Description:
    * @param dto
    * @param model
    * @Date:9:54 2021/7/1
    */
    @GetMapping(value = "lcselectJsrZx")
    public String lcselectJsr(ZxProjectDTO dto, Model model) {
        // 流程类型
        String type = dto.getType();
        String projectId = dto.getProjectId();
        String fileName = dto.getFileName();//
        String fileId = dto.getFileId();
        ZxProject pdto = zxProjectService.selectByPrimaryKey(projectId);
        // 查询业主单位负责人  监发两签流程需要选择业主单位负责人
        ProjectLeaderDTO projectLeaderdto = new ProjectLeaderDTO();
        projectLeaderdto.setSupervisorProjectId(projectId);
        List<ProjectLeaderDTO> listleader = projectLeaderService.selectProjectLeaderList(projectLeaderdto);
        //根据项目Id  查询 project_admin
//        ProjectAdmin projectAdmin = new ProjectAdmin();
//        projectAdmin.setSpId(projectId);
//        List<ProjectAdmin> projectAdminList = projectAdminService.select(projectAdmin);
//        if (projectAdminList.size() > 0) {
//            ProjectAdmin projectAdmin1 = projectAdminList.get(0);
//            String userId = projectAdmin1.getUId();
//            SysUser sysUser = sysUserService.selectByPrimaryKey(userId);
//            ProjectLeaderDTO dtofz = new ProjectLeaderDTO();
//            dtofz.setRealName("管理员");
//            dtofz.setProjectLeader(userId);
//            listleader.add(dtofz);
//
//        }


//        List<ProjectUnitConstructionDTO> listcj = null;
//        if ("004".equals(type)) {
//            // 监发三签
//            //查询承建单位
//            ProjectUnitConstructionDTO unitConstructiondto = new ProjectUnitConstructionDTO();
//            unitConstructiondto.setSupervisorProjectId(projectId);
//            listcj = projectUnitConstructionService.selectProjectUnitList(unitConstructiondto);
//        }
        model.addAttribute("type", type);
        model.addAttribute("projectId", projectId);
        model.addAttribute("fileName", fileName);
        model.addAttribute("fileId", fileId);
        model.addAttribute("listleader", listleader);
//        model.addAttribute("listcj", listcj);
        model.addAttribute("pdto", pdto);
        return "/act/supervisor/lcselectJsrZx";
    }



    /**
    * @Author:zhaoyongke
    * @Description:检测查询业主单位
    * @param dto
    * @param model
    * @Date:10:18 2021/7/21
    */
    @GetMapping(value = "lcselectJsrJc")
    public String lcselectJsrJc(ZxProjectDTO dto, Model model) {
        // 流程类型
        String type = dto.getType();
        String projectId = dto.getProjectId();
        String fileName = dto.getFileName();//
        String fileId = dto.getFileId();
        JcProject pdto = jcProjectService.selectByPrimaryKey(projectId);
        // 查询业主单位负责人  监发两签流程需要选择业主单位负责人
        ProjectLeaderDTO projectLeaderdto = new ProjectLeaderDTO();
        projectLeaderdto.setSupervisorProjectId(projectId);
        List<ProjectLeaderDTO> listleader = projectLeaderService.selectProjectLeaderList(projectLeaderdto);
        model.addAttribute("type", type);
        model.addAttribute("projectId", projectId);
        model.addAttribute("fileName", fileName);
        model.addAttribute("fileId", fileId);
        model.addAttribute("listleader", listleader);
//        model.addAttribute("listcj", listcj);
        model.addAttribute("pdto", pdto);
        return "/act/supervisor/lcselectJsrJc";
    }




}
